package com.flower8.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * @Description: 构造随机红包位置
 * @Author: tanglin
 * @Date: 2019/09/23 11:19
 * @Version: 1.0
 */
public class CreateRadomSeat {
    /**
     * 构造随机红包分布
     * @param goodsList
     * @return
     * @throws Exception
     */
    public static List<String> radomRedPage(List<Map> goodsList)throws Exception{
        long startTime = System.currentTimeMillis();

        List<String> list = new ArrayList();
        for (int i = 0; i < 1000000; i++) {
            list.add(goodsList.get(0).get("money").toString());
        }
        for (int i=0;i<45000;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(1).get("money").toString());
        }
        for (int i=0;i<3000;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(2).get("money").toString());
        }
        for (int i=0;i<800;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(3).get("money").toString());
        }
        for (int i=0;i<500;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(4).get("money").toString());
        }
        for (int i=0;i<400;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(5).get("money").toString());
        }
        for (int i=0;i<200;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(6).get("money").toString());
        }
        for (int i=0;i<100;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(7).get("money").toString());
        }

        /** ++++++++++++++++++++大额红包+++++++++++++++++++++++**/
        for (int i=0;i<50;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(8).get("money").toString());
        }

        for (int i=0;i<30;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(9).get("money").toString());
        }

        for (int i=0;i<20;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(10).get("money").toString());
        }

        for (int i=0;i<10;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(11).get("money").toString());
        }

        for (int i=0;i<9;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(12).get("money").toString());
        }

        for (int i=0;i<8;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(13).get("money").toString());
        }

        for (int i=0;i<7;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(14).get("money").toString());
        }

        for (int i=0;i<6;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(15).get("money").toString());
        }

        for (int i=0;i<5;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(16).get("money").toString());
        }
        long endTime = System.currentTimeMillis();
        System.out.println("总耗时："+(endTime-startTime)+"ms");
        return list;
    }

    /**
     * 构造随机大转盘分布
     * @param goodsList
     * @return
     * @throws Exception
     */
    public static List<String> radomBigWheel(List<Map> goodsList)throws Exception{
        long startTime = System.currentTimeMillis();
        List<String> list = new ArrayList();
        for (int i = 0; i < 1000000; i++) {
            list.add(goodsList.get(0).get("name").toString());
        }
        //500积分
        for (int i=0;i<150000;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(1).get("name").toString());
        }
        //1000积分
        for (int i=0;i<100000;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(2).get("name").toString());
        }
        //1500积分
        for (int i=0;i<45000;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(3).get("name").toString());
        }
        //2000积分
        for (int i=0;i<2500;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(4).get("name").toString());
        }
        //3000积分
        for (int i=0;i<1383;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(5).get("name").toString());
        }

        //0.1元红包
        for (int i=0;i<1000;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(6).get("name").toString());
        }
        //0.9元红包
        for (int i=0;i<100;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(7).get("name").toString());
        }
        //99.9元红包
        for (int i=0;i<10;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(8).get("name").toString());
        }
        //蓝牙耳机
        for (int i=0;i<5;i++){
            int rad = new Random().nextInt(1000000);
            list.set(rad,goodsList.get(9).get("name").toString());
        }
        //华为手机
        int rad = new Random().nextInt(1000000);
        list.set(rad,goodsList.get(10).get("name").toString());

        //苹果手机
        int radiPhone = new Random().nextInt(1000000);
        //去除位置重复
        while ("华为手机".equals(list.get(radiPhone))){
            radiPhone = new Random().nextInt(1000000);
        }
        list.set(radiPhone,"苹果手机");

        long endTime = System.currentTimeMillis();
        System.out.println("总耗时："+(endTime-startTime)+"ms");
        return list;
    }
}
